package com.yjd.bi.user.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.comm.util.FrameUtil;
import org.springframework.stereotype.Service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.bi.user.model.UserCustomerServiceModel;
import com.yjd.bi.user.service.IUserCustomerServiceService;
import com.yjd.bi.user.dao.IUserCustomerServiceDao;

/**
 * <b>description</b>：用户与客服关联表业务实现<br>
 * <b>time</b>：2018-08-20 11:40:04 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("userCustomerServiceService")
public class UserCustomerServiceServiceImpl extends BaseServiceImpl implements IUserCustomerServiceService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public UserCustomerServiceModel insert(UserCustomerServiceModel model) throws Exception {
		model.setCreate_time(FrameUtil.getTime());
		model.setUpdate_time(model.getCreate_time());
		return this.userCustomerServiceDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(UserCustomerServiceModel model) throws Exception {
		model.setUpdate_time(FrameUtil.getTime());
		return this.userCustomerServiceDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param user_id
	 * @return
	 * @throws Exception
	 */
	public int delete(long user_id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("user_id", user_id);
		return this.userCustomerServiceDao.deleteModel(paramMap, true);
	}

	@Override
	public void insertBatch(List<UserCustomerServiceModel> ucsm) throws Exception {
		userCustomerServiceDao.insertBatch(ucsm, true);
	}

	@Resource
	private IUserCustomerServiceDao userCustomerServiceDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.userCustomerServiceDao;
	}

}
